//
// Created by Scave on 2025/8/28.
//

#ifndef RIDER3D_EXTERNALLISTENER_H
#define RIDER3D_EXTERNALLISTENER_H

#include "Define.h"
#include "SceneEvent.h"
#include "entityx/Event.h"

NS_RIDER_BEGIN

    class Scene;

    class SceneEventListener : public Receiver<SceneEventListener> {
    public:
        static SMART_PTR<SceneEventListener> WithUpdated(FUNCTION<void(Scene* scene)> on_updated);

        SceneEventListener();

        SceneEventListener(
                FUNCTION<void(Scene* scene)> on_updated,
                FUNCTION<void(Scene* scene)> on_load = nullptr,
                FUNCTION<void(Scene* scene)> on_unload = nullptr
        );

        virtual void OnUpdated(Scene* scene);

        virtual void OnLoad(Scene* scene);

        virtual void OnUnLoad(Scene* scene);

        void receive(const SceneLoadEvent& event);

        void receive(const SceneUnLoadEvent& event);

        void receive(const SceneUpdatedEvent& event);

    private:
        FUNCTION<void(Scene* scene)> on_updated;
        FUNCTION<void(Scene* scene)> on_load;
        FUNCTION<void(Scene* scene)> on_unload;
    };
NS_RIDER_END

#endif //RIDER3D_EXTERNALLISTENER_H
